package com.cunzai.blog.common.conf;

import com.baomidou.mybatisplus.annotation.DbType;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyBatisPlusConfig {

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        // 使用 PaginationInnerInterceptor 实现分页
        PaginationInnerInterceptor paginationInterceptor = new PaginationInnerInterceptor();
        // 设置单页限制条数，默认 500 条，-1 不受限制
        paginationInterceptor.setMaxLimit(500L);
        paginationInterceptor.setDbType(DbType.POSTGRE_SQL);
        interceptor.addInnerInterceptor(paginationInterceptor);
        return interceptor;
    }
}


